package com.web.service.impl;

import com.web.dao.UserDAO;
import com.web.dao.impl.UserDAOImpl;
import com.web.entity.User;
import com.web.service.UserService;

/**
 * 用户业务逻辑实现类
 */
public class UserServiceImpl implements UserService {

    //创建dao对象
    private UserDAO userDAO = new UserDAOImpl();
    @Override
    public User login(String username, String password) {
        //通过用户名查用户
        User user = userDAO.selectUserByUsername(username);
        //验证用户是否存在，密码是否正确
        if(user != null){
            if(password.equals(user.getPassword())){
                return user;
            }
        }
        return null;
    }

    @Override
    public void updateUser(User user) {
        userDAO.updateUser(user);
    }
}
